<template>
  <view class="content">
    <block v-if="item">
      <view class="top-img">
        <image :src="this.$store.state.imgBaseUrl + '/join-big-1.png'"></image>
      </view>
      <view class="r-text">
        <text v-if="item">
          {{item.statusName}}
        </text>
      </view>
      <view class="hint" v-if="item.status == 0">
        请耐心等待1-2个工作日，我们会尽快为您审核，请留意您的短信或系统通知！
      </view>
      <view class="hint" v-else>
        <!-- <view>{{item.statusName}}</view> -->
        <view>{{item.userQualification2mVo.remark}}</view>
        <view>{{item.accountTransferVo.ideaRemark}}</view>
      </view>
      <view class="icon-list" v-if="item.status != 0">
        <view class="box" :class="{over: item.userQualification2mVo.status != 0}">
          <image src="../../static/image/join-sm-2.png" v-if="item.userQualification2mVo.status == 0"></image>
          <image src="../../static/image/join-sm-1.png" v-if="item.userQualification2mVo.status == 1"></image>
          <image src="../../static/image/join-sm-3.png" v-if="item.userQualification2mVo.status == 2 || item.userQualification2mVo.status == 3"></image>
          <view>
            资质认证
          </view>
        </view>
        <view class="line"></view>
        <view class="box" :class="{over: item.accountTransferVo.status != 0}">
          <image src="../../static/image/join-sm-2.png" v-if="item.accountTransferVo.status == 0"></image>
          <image src="../../static/image/join-sm-1.png" v-if="item.accountTransferVo.status == 1"></image>
          <image src="../../static/image/join-sm-3.png" v-if="item.accountTransferVo.status == 2 || item.accountTransferVo.status == 3"></image>
          <view>
            费用缴纳
          </view>
        </view>
      </view>
      <view class="footer" v-if="item.status != 0 && item.status != 1">
        <button type="primary" class="sub-btn cur" plain="true" @click="draw">重新申请</button>
      </view>
    </block>
  </view>
</template>

<script>
import { reviewQualification, findResult } from '../../service/join/join.service.js'
export default {
  data() {
    return {
      title: {
        0: '审核中',
        1: '审核通过',
        2: '市场失败',
        3: '财务失败',
        4: '市场驳回',
        5: '财务驳回',
        6: '审核失败'
      },
      item: null
    };
  },
  onShow:function() {
    this.getInfo();
  },
  methods: {
    getInfo () {
      findResult({}, (res) => {
        if (res.status == 0) {
          if (res.data) { // 已申请过加盟
            uni.setNavigationBarTitle({
              title: this.title[res.data.status]
            })
            this.item = res.data;
            if (res.data.currentRank > 1) { // 审核成功去首页
              uni.switchTab({
                url: '/pages/index/index'
              })
            }
          } else { // 未申请加盟去加盟入住页
            uni.navigateTo({
              url: '/pages/subsidiaryJoin/index'
            })
          }
        } else {
          uni.showToast({
            title: res.msg,
            icon: 'none'
          });
        }
      })
    },
    draw () {
      /**
      this.item.status: 0待审核 1审核通过
            2资质审核失败 3财务审核失败
            4资质驳回 5财务驳回 6市场财务均驳回
      **/
      if (this.item.status == 2 || this.item.status == 3) {
        uni.navigateTo({
          url: '/pages/subsidiaryJoin/index'
        })
      } else if (this.item.status == 4 || this.item.status == 6) {
        this.item.userQualification2mVo['appliedType'] = this.item.appliedType;
        uni.setStorage({ // 存储加盟信息
          key: 'recomposeDatas',
          data: this.item.userQualification2mVo, // 资质信息
          success: () => {
            // joinType   加盟类型 enterprise企业 person个人
            // leagueAttitude： 加盟等级
            let type = this.item.userQualification2mVo.joinType == 0 ? 'enterprise' : 'person';
            uni.navigateTo({
              url: '/pages/subsidiaryJoin/identityAuthen?grade='+ this.item.userQualification2mVo.leagueAttitude +'&type=' + type
            })
          }
        })
      } else if (this.item.status == 5) {
        // 去支付
        // joinType   加盟类型 enterprise企业 person个人
        // leagueAttitude： 加盟等级
        uni.navigateTo({
          url: '/pages/purchaseShop/orderPay?grade=' + this.item.userQualification2mVo.leagueAttitude + '&type=' + this.item.userQualification2mVo.joinType
        });
      }
      
    }
  }
}
</script>

<style scoped lang="scss">
.content {
  height: 100vh;
  background-color: #FFFFFF;
}
image {
  width: 100%;
  height: 100%;
}
.result {
  padding-top: 40rpx;
  height: 100vh;
  background-color: #FFFFFF;
}
.top-img {
  width: 330rpx;
  height: 330rpx;
  margin: 0 auto 30rpx;
}
.r-text {
  text-align: center;
  font-size: 36rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #333333;
}
.hint {
  font-size: 30rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #999999;
  margin-top: 52rpx;
  text-align: center;
  padding: 0 60rpx;
  line-height: 1.6;
}
.icon-list {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 150rpx;
  .box {
    color: #999999;
    font-size: 29rpx;
    image {
      display: block;
      width: 51rpx;
      height: 51rpx;
      margin: 0 auto 25rpx;
    }
    &.over {
      color: #434343;
    }
  }
  .line {
    width: 87rpx;
    height: 1px;
    background: #E1E1E1;
    margin-left: 18rpx;
    margin-right: 29rpx;
  }
}
.footer {
  width: 100%;
  border-top: 1px solid #E1E1E1;
  padding: 14rpx 0 20rpx;
  background-color: #FFFFFF;
  position: absolute;
  bottom: 0;
  left: 0;
  button {
    height: 70rpx;
    margin: 0 32rpx;
    background-color: #636363;
    font-size: 30rpx;
    line-height: 70rpx;
    color: #ADA697;
    border: none;
    &.cur {
      color: #F6DA99;
      background-color: #434343;
    }
  }
}
</style>
